#
# Copyright (C) 2009 Christoph Caks
#
# This file is part of GLWAK.
#
# GLWAK is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GLWAK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with GLWAK.  If not, see <http://www.gnu.org/licenses/>.
#
#
# CMakeLists.txt
#
#  Created on: 08.07.2009
#      Author: Christoph Caks
#

cmake_minimum_required( VERSION 2.6 )
project( GLWAK )

set( LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib )
set( EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin )

find_package( Boost 1.36.0 COMPONENTS 
	thread )

#add_library( GLEW MODULE IMPORTED )
#add_library( GLEW1 STATIC IMPORTED )
#add_library( GLEW2 STATIC IMPORTED )

# TODO: figure out what -DNOMINMAX does and why it won't compile on without it
IF(WIN32)

	add_library( OpenThreads MODULE IMPORTED )
	set_property( TARGET OpenThreads PROPERTY IMPORTED_LOCATION ./libs/OpenThreads-2.3.0/libOpenThreads.dll )

    set_property( TARGET GLEW PROPERTY IMPORTED_LOCATION ./libs/GLEW-1.5.1/glew32.dll )
    set_property( TARGET GLEW1 PROPERTY IMPORTED_LOCATION  ./libs/GLEW-1.5.1/glew32.lib )
    set_property( TARGET GLEW2 PROPERTY IMPORTED_LOCATION ./libs/GLEW-1.5.1/glew32s.lib )

	add_definitions( -DGLWAK_WINDOWS -DNOMINMAX -DRTTI )
	set( SYS_INCLUDES )
	set( SYS_SOURCES
		src/windows/WindowsContext
		src/windows/WindowsWindow
		src/windows/WindowsHelper
    )
	set( SYS_LIBS
		opengl32
		gdi32
	)
ELSEIF(UNIX)
	add_definitions( -DGLWAK_X11 )
	set( SYS_INCLUDES
		/usr/include
	)
	set( SYS_SOURCES
		src/x11/X11Window
		src/x11/X11Context
	)
	set( SYS_LIBS
		GL
		X11
		Xxf86vm
	)
ENDIF(WIN32)

set( COMMON_INCLUDES
	include
)
set( COMMON_SOURCES
	src/GLWAKFactory
	src/ContextConfiguration
	src/Context
	src/WindowConfiguration
	src/Window
	src/Drawable
	src/Initializeable )
	
set( COMMON_LIBS
	GLWAK
	GLEW # GLEW1 GLEW2
)
	
include_directories(
	${SYS_INCLUDES}
	${COMMON_INCLUDES} )

add_library( GLWAK SHARED
	${COMMON_SOURCES}
	${SYS_SOURCES} )

target_link_libraries (
    ${COMMON_LIBS}
	${SYS_LIBS}
	${Boost_LIBRARIES}
)

# glwakTest
add_executable( glwakTest
	src/glwakTest )
	
target_link_libraries( glwakTest
    GLWAK
    OpenThreads )
	
add_dependencies( glwakTest
	GLWAK )

# windowTest
add_executable( windowTest
    src/windowTest )
    
target_link_libraries( windowTest 
    GLWAK
    OpenThreads )

add_dependencies( windowTest
    GLWAK )

